package edu.luc.concordia;
import java.awt.*;
import java.awt.event.ActionListener;

import javax.swing.*; 

/**
 * Copyright 2008 Project Concordia
 * <p>
 * This file is part of RetailReturnSystem.
 * <p>
 * RetailReturnSystem is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * <p>
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * <p>
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.
 * <hr>
 * This class creates Different Panels
 * @param str Header of the Panel
 * @param panelName Name of the Panel
 * @author Rashmi Pandey & Piyushaben Desai
 * @version 0.1 2008-10-10
 */
public class Display extends JFrame 
{
	public Display(String str, String panelName, ActionListener listener)
	{
		//Provide Panel Setting Parameters here 
		 
		setTitle (str);
		setSize (550, 550);
		centerWindow(this);
		setResizable (true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		JPanel panel = null;
		if (panelName.equals(PanelGenerator.SYSTEM_START_PANEL))
		{
			panel = new SystemStart();
			setSize (550, 200);
			centerWindow(this);
			((SystemStart)panel).addActionListener(listener);
		} 
		else if (panelName.equals(PanelGenerator.SUMMARY_DISPLAY_PANEL))
		{
			panel = new SystemSummary(this);
			((SystemSummary)panel).addActionListener(listener);
			((Translation)listener).addPropertyChangeListener((SystemSummary)panel);
		
		} 
		else if (panelName.equals(PanelGenerator.SYSTEM_MAIN_PANEL))
		{
			panel = new SystemMain(this);
			((SystemMain)panel).addActionListener(listener);
		} 
		else if (panelName.equals(PanelGenerator.RECEIPT_PANEL))
		{
			panel = new Receipt(this);
			((Receipt)panel).addActionListener(listener);
		}
		else if (panelName.equals(PanelGenerator.SYSTEM_SHUTDOWN_PANEL))
		{
			panel = new SystemShutDown(this);
			setSize(520,200);
			centerWindow(this);
		}
		this.add(panel);		
	}
	
	/*
	 * Method to set position of panel
	 */
	private void centerWindow(Window w)
	{		
		Toolkit tk = Toolkit.getDefaultToolkit();
		Dimension d = tk.getScreenSize();
		this.setLocation((d.width-w.getWidth())/2, (d.height-w.getHeight())/2);
	}	
	
}



